package com.heyqing.ems.controller;

import com.heyqing.ems.po.LoginPo;
import com.heyqing.ems.service.LoginService;
import com.heyqing.ems.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName:LoginController
 * Package:com.heyqing.ems.controller
 * Description:
 *
 * @Date:2024/6/26
 * @Author:Heyqing
 */
@Api(value = "登录")
@RestController
@RequestMapping("login")
@RequiredArgsConstructor
public class LoginController {

    private final LoginService loginService;

    /**
     * 用户登录
     *
     * @param loginPo
     * @return
     */
    @ApiOperation("登录方法")
    @PostMapping
    public Result login(@RequestBody LoginPo loginPo) {
        return loginService.login(loginPo);
    }

    /**
     * 检查登录
     *
     * @param token
     * @return
     */
    @ApiOperation("检查登录")
    @PutMapping("check")
    public Result check(@RequestHeader("token") String token) {
        return loginService.check(token);
    }
}
